﻿

Imports System.Data
Imports VSModel
Imports Cls_Common
Partial Class Control_ToDo_PortletNhacViec
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim _UserId As Integer = Session("UserId")
            BindToGrid(_UserId)
        End If
    End Sub

    Protected Sub BindToGrid(ByVal _LoaiNguoiDung As Integer)


        Using _data As New VSEntities
            ' mot cua
            Dim curDate As Date = Now.Date
       '     Dim p = (From q In _data.ToDoLists Where q.UserId = _LoaiNguoiDung Where q.IsActive = True And (curDate >= q.RemindDate And curDate <= q.DueDate) Order By q.StartDate Ascending Select q).ToList
            Dim p = (From q In _data.ToDoLists Where q.UserId = _LoaiNguoiDung And q.IsActive = True And (curDate >= q.RemindDate And curDate <= q.DueDate) Order By q.StartDate Ascending Select q).ToList
            ltrNhacViec.Text = p.Count
            With rptNhacViec
                .DataSource = p
                .DataBind()
            End With
           
        End Using
    End Sub
    Protected Sub rptTiepNhan_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptNhacViec.ItemDataBound
        Dim row = CType(e.Item.DataItem, ToDoList)
        Dim hplTitle As HyperLink = e.Item.FindControl("hplTitle")
        hplTitle.Text = row.Subject & " - " & CType(row.StartDate, Date).ToString("dd/MM/yyyy")
        hplTitle.NavigateUrl = MainDomain & "Page/ToDo/Detail.aspx?Id=" & row.Id

    End Sub
End Class
